import {getCache, getTempCache} from '../utils/localStorage.js'

const getters = {
  token: state => state.user.token,
  readRecords: (state) => {
    if (state.user.readRecords.length>0) {
      return state.user.readRecords
    }else {
      return getCache('readRecords')
    }
  },
  collectRecords: (state) => {
    if (state.user.collectRecords.length>0) {
      return state.user.collectRecords
    }else {
      return getCache('collectRecords')
    }
  },

  showTabPanel: state => state.home.showTabPanel,
	winWidth: state => state.home.winWidth,
  winHeight: state => state.home.winHeight,
  bannerData: state => state.home.bannerData,
  themeData: state => state.home.themeData,
  showToTop: state => state.home.showToTop,
  
  isRollVertical: state => state.reader.isRollVertical,
  showReadHeaderBar: state => state.reader.showReadHeaderBar,
  showReadMenuBar: state => state.reader.showReadMenuBar,
  currentReadCID: state => state.reader.currentReadCID,
  currentReadSID: state => state.reader.currentReadSID,
  currentReadSections: state => state.reader.currentReadSections,
  currentReadProgress: state => state.reader.currentReadProgress,

  showSearchPanel: state => state.search.showSearchPanel,
  oldSearchRecords: (state) => {
    if (state.search.oldSearchRecords.length>0){
      return state.search.oldSearchRecords
    }else {
      return getCache('oldSearchRecords')
    }
  },
  hotSearchRecords: (state) => {
    if (state.search.hotSearchRecords.length>0){
      return state.search.hotSearchRecords
    }else {
      return getTempCache('hotSearchRecords')
    }
  }
  
};
export default getters